<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--    引入semantic.min.css-->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
  <!--    引入me.css-->
  <link rel="stylesheet" href="../../static/css/me.css">
  <title>分类管理</title>
</head>
<body>

<!--导航-->
<nav th:replace="admin/_fragments :: menu(2)" class="ui inverted attached segment m-padded-tb-mini">
  <div class="ui container"> <!-- 加一个容器 -->
    <div class="ui inverted secondary stackable menu"> <!-- 菜单 stackable:可堆叠的,表示屏幕小时自动堆叠-->
      <h2 class="ui white header item">GuideSystem</h2> <!-- 蓝绿色标题 -->
      <a href="#" class="m-item m-mobile-hide item"><i class="home icon"></i>博客</a> <!-- icon表示图表 -->
      <a href="#" class="active m-item m-mobile-hide item"><i class="idea icon"></i>分类</a>
      <a href="#" class="m-item m-mobile-hide item"><i class="tags icon"></i>标签</a>
      <div class="right m-item m-mobile-hide menu">
        <div class="ui dropdown item">
          <div class="text">
            <img class="ui avatar image" src="https://unsplash.it/100/100?image=1005">
            软件214项目组
          </div>
          <i class="dropdown icon"></i>
          <div class="menu">
            <a href="#" class="item">注销</a>
          </div>
        </div>
      </div>
    </div>
  </div>
  <a href="#" class="ui menu toggle black button icon m-top-right m-mobile-show">
    <i class="sidebar icon"></i>
  </a>
</nav>
<div cLass="ui attached pointing menu" style="margin-top: 4.4em;">
  <div class="ui container">
    <div class="right menu">
      <a href="#" th:href="@{/admin/types/input}" class="blue item">新增</a>
      <a href="#" th:href="@{/admin/types}" class="blue active item">列表</a>
    </div>
  </div>
</div>


<!--中间内容-->
<div class="m-container m-padded-tb-big" id="contentDiv">
  <div class="ui container">
    <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
      <i class="close icon"></i>
      <div class="header">提示：</div>
      <p th:text="${message}">操作成功。</p>
    </div>
    <!--        表格-->
    <table class="ui celled table">
      <!--            表头-->
      <thead>
      <tr>
        <th></th>
        <th>名称</th>
        <th>操作</th>
      </tr>
      </thead>
      <!--            表体-->
      <tbody>
      <tr th:each="type, iterStat : ${page.content}">
        <td th:text="${iterStat.count}">1</td>
        <td th:text="${type.name}">刻意练习清单</td> <!--从type对象中拿到对象的name属性-->
        <td>
          <a href="#" th:href="@{/admin/types/{id}/input(id=${type.id})}"
             class="ui mini blue basic button">编辑</a>
          <a href="#" th:href="@{/admin/types/{id}/delete(id=${type.id})}"
             class="ui mini gray basic button">删除</a>
        </td>
      </tr>
      </tbody>
      <!--            表尾-->
      <tfoot>
      <tr>
        <th colspan="6">
          <div class="ui pagination menu" th:if="${page.totalPages}>1">
            <!--th:unless="${page.first}"表示如果不是第一页，这个item才会显示-->
            <a th:href="@{/admin/types(page=${page.number}-1)}" class="item" th:unless="${page.first}">上一页</a>
            <a th:href="@{/admin/types(page=${page.number}+1)}" class="item" th:unless="${page.last}">下一页</a>
          </div>
          <a href="#" th:href="@{/admin/types/input}"
             class="ui mini right floated blue basic button m-padded-tb m-padded-lr m-margin-top-small">新增</a>
        </th>
      </tr>
      </tfoot>
    </table>
    <!--        <div class="ui mini floated red basic button m-padded-tb m-padded-lr m-margin-top-small">-->
    <!--            共计分类：<p class="ui m-inline-block">6</p>个-->
    <!--        </div>-->
  </div>
</div>

<!--底部footer-->
<footer th:replace="admin/_fragments :: footer" class="ui inverted vertical segment m-padded-tb-massive">
  <!-- vertical:垂直的 segment:条横 inverted:倒置的 -->
  <div class="ui center aligned container"> <!-- center aligned:居中 aligned:使成为一条线-->
    <div class="ui inverted divided stackable grid"> <!-- inverted divided grid:格线分成16份 -->
      <div class="three wide column">
        <div class="ui inverted link list">
          <div class="item">
            <img src="../../static/images/WeChat.jpg" class="ui rounded image" alt="" style="width: 110px">
            <!-- rounded:圆角 -->
          </div>
        </div>
      </div>

      <!-- 分成三列 -->
      <div class="three wide column">
        <h4 class="ui inverted header m-text-thin">最新博客</h4>
        <div class="ui inverted link list">
          <a href="#" class="item m-text-thin">用户故事(User Story)</a>
          <a href="#" class="item m-text-thin">关于小熊是我对象这件事</a>
          <a href="#" class="item m-text-thin">摇滚乐牛逼!</a>
        </div>
      </div>

      <!-- 分成三列 -->
      <div class="three wide column">
        <h4 class="ui inverted header m-text-thin">联系我</h4>
        <div class="ui inverted link list">
          <a href="#" class="item m-text-thin" style="height: 28px">QQ: 1923326384</a>
          <a href="#" class="item m-text-thin">邮箱: 1923326384@qq.com</a>
        </div>
      </div>

      <!-- 分成七列 -->
      <div class="seven wide column">
        <h4 class="ui inverted header m-text-thin">个人留言</h4>
        <p class="m-text-thin m-text-spaced m-opacity-mini m-text-lined">
          第一次跟着视频敲项目，尽管很多不知道的知识点但还是慢慢吞吞地敲下来了，后续肯定会自己独立完成一些项目，希望可以鼓励到自己。</p>
      </div>

    </div>
    <div class="ui inverted section divider"></div>
    <p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright @ 2021-2022 Hanyufan Designed by Hanyufan</p>
  </div>
</footer>

<th:block th:replace="admin/_fragments :: script">
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
</th:block>

<!--点击执行操作-->
<script>
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });
    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    $('.message .close').on('click', function () {
        $(this).closest('.message').transition('fade');
    });

    window.addEventListener('resize', function () {
        let myDiv = document.getElementById('contentDiv');
        if (myDiv.clientHeight < 550) {
            myDiv.style.height = '550px';
        } else {
            // 如果之前已经设置了固定的550px高度，这里可以取消设置以恢复原始高度
            myDiv.style.height = '';
        }
    });

    // 页面加载完成后执行一次检查
    (function () {
        let myDiv = document.getElementById('contentDiv');
        if (myDiv.clientHeight < 550) {
            myDiv.style.height = '550px';
        }
    })();

</script>
</body>
</html>